import React, { useEffect, useState } from 'react'
import { Layout, Table } from 'antd'
import { adminList } from 'src/api/getData'
import './index.less'

const { Content } = Layout;
const OrderInfo = (props) => {

    const [dataSource, setDataSource] = useState([])

    useEffect(() => {
        //request商品详情
        async function initData() {
            try {
                const res = await adminList({ offset: 0, limit: 10 });
                const data = res.data.map(item => {
                    return {
                        create_time: item.create_time,
                        user_name: item.user_name,
                        admin: item.admin,
                        city: item.city,
                    }
                })
                setDataSource(data)
            } catch (err) {
                console.log('获取数据失败', err);
            }
        }
        initData()
    }, [])

    function onShowSizeChange(current, pageSize) {

    }

    return <Layout>
        <Content>
            <Table
                columns={[
                    {
                        title: '姓名',
                        dataIndex: 'user_name'
                    },
                    {
                        title: '地址',
                        dataIndex: 'city'
                    },
                    {
                        title: '权限',
                        dataIndex: 'admin'
                    },
                    {
                        title: '注册日期',
                        dataIndex: 'create_time'
                    },
                ]}
                dataSource={dataSource}
                pagination={{
                    defaultCurrent: 1,
                    total: 50,
                    showSizeChanger: true,
                    onShowSizeChange,
                    showQuickJumper: true,
                    onChange: onShowSizeChange
                }}
            />
        </Content>
    </Layout>
}
export default OrderInfo